package com.xbts.system.domain;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xbts.common.core.annotation.Excel;
import com.xbts.common.core.web.domain.BaseIdEntity;
import com.xbts.common.core.utils.StringUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Update;

import javax.validation.constraints.NotEmpty;

/**
 * 第三方系统路径对象 sys_third_sys_path
 *
 * @author llk
 * @date 2023-12-22
 */
@Data
@ApiModel(value = "SysThirdSysPath", description = "第三方系统路径对象")
@TableName("sys_third_sys_path")
@NoArgsConstructor
public class SysThirdSysPath extends BaseIdEntity {
    private static final long serialVersionUID = 1L;

    /**
     * 系统名称
     */
    @Excel(name = "系统名称")
    @ApiModelProperty("系统名称")
    private String systemName;

    /**
     * 系统图标地址
     */
    @Excel(name = "系统图标地址")
    @ApiModelProperty("系统图标地址")
    private String logoPath;

    /**
     * 系统地址
     */
    @Excel(name = "系统地址")
    @ApiModelProperty("系统地址")
    @NotEmpty(message = "系统地址不能为空", groups = {Insert.class})
    private String systemUrl;

//    /**
//     * 链接参数
//     */
//    @Excel(name = "链接参数")
//    @ApiModelProperty("链接参数")
//    private String urlParams;

    /**
     * 账号字段
     */
    @Excel(name = "账号字段")
    @ApiModelProperty("账号字段")
    @NotEmpty(message = "账号字段不能为空", groups = {Insert.class, Update.class})
    private String usernameField;

    /**
     * 密码字段
     */
    @Excel(name = "密码字段")
    @ApiModelProperty("密码字段")
    private String passwordField;

    public <T> QueryWrapper<T> queryWrapper() {
        QueryWrapper<T> wrapper = new QueryWrapper<>();
        wrapper.like(StringUtils.isNotEmpty(systemName), "system_name", systemName);
        wrapper.like(StringUtils.isNotEmpty(logoPath), "logo_path", logoPath);
        wrapper.like(StringUtils.isNotEmpty(systemUrl), "system_url", systemUrl);
        return wrapper;
    }
}
